package model

import (
	"base"
)

type Player struct {
	id             base.PlayerId
	gameId         base.AgentId
	client         *Client
	loginTimestamp int64
}

func NewPlayer(id base.PlayerId, gameId base.AgentId) *Player {
	result := new(Player)
	result.id = id
	result.gameId = gameId

	return result
}

func (player *Player) Id() base.PlayerId {
	return player.id
}

func (player *Player) GameId() base.AgentId {
	return player.gameId
}

func (player *Player) Client() *Client {
	return player.client
}

func (player *Player) SetClient(client *Client) {
	player.client = client
}

func (player *Player) LoginTimestamp() int64 {
	return player.loginTimestamp
}

func (player *Player) SetLoginTimestamp(loginTimestamp int64) {
	player.loginTimestamp = loginTimestamp
}

func (player *Player) Clear() {
	player.id = base.InvalidPlayerId
	if player.client != nil {
		player.client.SetPlayer(nil)
		player.client = nil
	}
	player.loginTimestamp = 0
}
